package jym.tan.movielibrary.factory;

import java.util.ArrayList;
import java.util.List;

import javax.swing.DefaultComboBoxModel;
import javax.swing.table.TableModel;

import jym.tan.movielibrary.component.ui.combobox.model.ThemeComboBoxModel;
import jym.tan.movielibrary.component.ui.table.model.MovieSearchResultTableModel;
import jym.tan.movielibrary.model.MovieSearchModel;
import jym.tan.movielibrary.utils.ModelUtils;

public class ModelFactory {

	private static MovieSearchResultTableModel movieSearchResultTableModel;
	private static ThemeComboBoxModel themeComboBoxModel;
	
	public static synchronized TableModel getMovieSearchResultTableModel() {
		if(movieSearchResultTableModel == null) {
			movieSearchResultTableModel = new MovieSearchResultTableModel();
			List<MovieSearchModel> movieSearchModels = new ArrayList<MovieSearchModel>(0);
			movieSearchResultTableModel.setMovieSearchModels(movieSearchModels);
		}
		return movieSearchResultTableModel;
	}
	
	public static DefaultComboBoxModel getThemeComboBoxModel() {
		if(themeComboBoxModel == null) {
			themeComboBoxModel = new ThemeComboBoxModel(ModelUtils.getThemeModels());
			themeComboBoxModel.setThemeModels(ModelUtils.getThemeModels());
		}
		return themeComboBoxModel;
	}
}
